import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: jingziyou
 * Date: 2023-03-01
 * Time: 20:41
 */
public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean[] c = new boolean[2000000];
        double[] a = new double[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextDouble();
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            while (b[i] > 0) {
                int q = (int) (a[i] * b[i]--);
                c[q] = !c[q];
            }
        }
        for (int i = 0; i < c.length; i++) {
            if (c[i]) {
                System.out.println(i);
                break;
            }
        }
        sc.close();
    }
}

